package com.ruoyi.camp.api;


import com.ruoyi.camp.domain.CCampsite;
import com.ruoyi.camp.service.ICCampsiteService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(value = "微信营位接口")
@RestController
@RequestMapping("/wechat/campsite")
public class WxCampsiteController extends BaseController {

    @Autowired
    private ICCampsiteService cCampsiteService;

    @ApiOperation("微信查询营位")
    @GetMapping("/list")
    public TableDataInfo list(CCampsite cCampsite)
    {
        List<CCampsite> list = cCampsiteService.selectCCampsiteList(cCampsite);

        return getDataTable(list);
    }

    /**
     * 获取营地营位功能详细信息
     */
    @ApiOperation("微信根据ID查询营位")
    @GetMapping(value = "/{campsiteId}")
    public AjaxResult getInfo(@PathVariable("campsiteId") String campsiteId)
    {

        System.out.println("营位条件："+cCampsiteService.selectCCampsiteByCampsiteId(campsiteId));
        return success(cCampsiteService.selectCCampsiteByCampsiteId(campsiteId));

    }

    /**
     * 新增营地营位功能
     */
    @ApiOperation("微信新增营位")
    @PostMapping
    public AjaxResult add(@RequestBody CCampsite[] cCampsite)
    {
        return toAjax(cCampsiteService.insertCCampsite(cCampsite));
    }

    /**
     * 修改营地营位功能
     */
    @ApiOperation("微信修改营位")
    @PutMapping
    public AjaxResult edit(@RequestBody CCampsite cCampsite)
    {
        return toAjax(cCampsiteService.updateCCampsite(cCampsite));
    }

    /**
     * 删除营地营位功能
     */
    @ApiOperation("微信删除营位")
    @DeleteMapping("/{campsiteIds}")
    public AjaxResult remove(@PathVariable String[] campsiteIds)
    {
        return toAjax(cCampsiteService.deleteCCampsiteByCampsiteIds(campsiteIds));
    }
}
